function Update-Insight {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)][Parameters]$Parameters
    )

    Write-Host # Newline.
    Write-host "Updating LS Insight..."

    # Do necessary update preperations.
    Start-UpdatePreperation -Parameters $Parameters 

    # Insert values into arm_template_parameters.
    Complete-ArmTemplateParameterFile -Parameters $Parameters
    
    # Configure the ADFv2.
    $params = @{
        ResourceGroupName = $Parameters.Azure.ResourceGroup
        ADFv2Name = $Parameters.LSInsight.ADFv2.Name
        ProjectTemplateFile = $Parameters.LSInsight.ArmTemplateFile
        ProjectTemplateParameterFile = $Parameters.LSInsight.ArmTemplateParameterFile
        LSCentralPassword = $Parameters.LSCentral.Server.Credential.Password
        LSInsightPassword = $Parameters.LSInsight.Server.Credential.Password
    }

    Set-AzureDataFactoryV2 @params
    Write-Host "The Azure data factory pipelines are now updated!"
    Write-Host
    Write-Host "Checking if updates are needed in the data warehouse."

    Run-UpdateDBScripts -LSInsight $Parameters.LSInsight
   
      # Store 'Parameters' object in the project folder.
    if ($Parameters.LSInsight.ParametersOutFilePath) {
        Write-LSParameters -Parameters $Parameters -File $Parameters.LSInsight.ParametersOutFilePath
    }

    Show-InsightParameters -LSInsight $Parameters.LSInsight  

    Write-Host "Done!"
    Write-Host "LS Insight is now updated"
    Write-Host # Newline.

    <#
    .SYNOPSIS
        Updates LS Insight.
    .DESCRIPTION
        The Update-Insight function updates to the latest version of LS Insight.
        
        The function sets up the necessary Azure resources for LS Insight.

        A typical LS Insight deployment consists of these Azure resources:
        - Azure SQL server.
        - Azure SQL database.
        - Azure Data Factory v2.
    .EXAMPLE
        PS C:\> Update-Insight -Parameters $Params

        Update LS Insight.
    .INPUTS
        None. You cannot pipe objects to Update-Insight.
    .OUTPUTS
        None.
    .PARAMETER Parameters
        A 'Parameters' type object that describes the deployment process.
        A recipe for the LS Insight instance.
        Required?                    true
        Position?                    
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
    .NOTES
        Even though there are no direct outputs from this function, some things are created.
        If the deployment process is successful, then the 'Parameters' object used to define the deployment is stored in the project folder.
        Depending on the deployment, some files might have been added to the project folder that were used during the deployment.
    #>
}